#!/bin/bash
# -*- coding: utf-8 -*-


"""
⽤户登录（三次输错机会）且每次输错误时显示剩余错误次数（提示：使⽤字符串格式化），登录成功就退出循环。
需求：
    当用户输入的用户名等于 zhangkai 密码等于 123 时，提示登录成功，并退出程序，否则提示登录失败
"""

user_name = '张开'
password = 123
# 当用户输入的用户名和密码等于上面的用户名和密码时，退出循环，有三次机会，请你补全后续代码，完成三次登录

# user = input('user: ').strip()
# pwd = int(input('pwd: ').strip())   # 要注意，只有输入的是整数才能int强转
# # print(user, pwd, type(pwd))
# if user == user_name and pwd == password:
#     print('登录成功')
# else:
#     print('登录失败')

# count = 0
# while count < 3:
#     user = input('user: ').strip()
#     pwd = int(input('pwd: ').strip())  # 要注意，只有输入的是整数才能int强转
#     if user == user_name and pwd == password:
#         print('登录成功')
#         break
#     else:
#         # print('登录失败')
#         count += 1
#         # if 3 - count == 0:
#         if count == 3:
#             print('登录失败，你没有机会了')
#         else:
#             print('登录失败，你还有[{}]次尝试机会'.format(3 - count))


# count = 3
# while count > 0:
#     user = input('user: ').strip()
#     pwd = int(input('pwd: ').strip())  # 要注意，只有输入的是整数才能int强转
#     if user == user_name and pwd == password:
#         print('登录成功')
#         break
#     else:
#         count -= 1
#         if count == 0:
#             print('登录失败，你没有机会了')
#         else:
#             print('登录失败，你还有[{}]次尝试机会'.format(count))

# for i in range(2, -1, -1):
#     user = input('user: ').strip()
#     pwd = int(input('pwd: ').strip())  # 要注意，只有输入的是整数才能int强转
#     if user == user_name and pwd == password:
#         print('登录成功')
#         break
#     else:
#         if i == 0:
#             print('登录失败，你没有机会了')
#         else:
#             print('登录失败，你还有[{}]次尝试机会'.format(i))











